package iziswing.composant;

import java.awt.Container;
import java.awt.Point;

import javax.swing.JComponent;

import metier.ContexteComposant;

import org.apache.log4j.Logger;

@SuppressWarnings("serial")
public class JLabel extends javax.swing.JLabel{

	private static Logger mLogger = Logger.getLogger(JLabel.class.getName());

	private ContexteComposant mContexte;
	private Container mFenetre;
	
	private JLabel(Container aFenetre, ContexteComposant aContexte){
		super(aContexte.getDefaut());
		mFenetre = aFenetre;
		mContexte = aContexte;
		Point lPoint = ComposantTools.getSize(mContexte);
		setBounds(mContexte.getX(),mContexte.getY(),lPoint.y,lPoint.x);
		mFenetre.add(this);
	}
	
	public JLabel(){
		super("test");
	}
	
	@SuppressWarnings("unchecked")
	public static Object newInstance(Container aFenetre , ContexteComposant aContexte,Object aComposantOut){
		try {
			Class<JComponent> lComposant = (Class<JComponent>) Class.forName(aContexte.getModeleClasse().getClasse());
			if(lComposant.equals(JLabel.class)){
				aComposantOut = new JLabel(aFenetre, aContexte); 
			}
		} catch (ClassNotFoundException e) {
			mLogger.debug(e);
		}
		return aComposantOut;
	}
}
